Skip to content

Manchester | 26-ITP-Sep | Salah Alsabhi | Sprint 2 | practice tdd - #1680

Open
salahalsabhi wants to merge 4 commits into
CodeYourFuture:mainfrom
salahalsabhi:coursework/sprint-2-practice-tdd
Open

salahalsabhi wants to merge 4 commits into
CodeYourFuture:mainfrom
salahalsabhi:coursework/sprint-2-practice-tdd

Conversation

@salahalsabhi

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Task code

CYF-1060

Changelist

Practice TDD: countChar, repeatStr, getOrdinalNumber

Questions

No questions

@github-actions

This comment has been minimized.

@salahalsabhi salahalsabhi changed the title Manchester | 26-ITP-Sep | Salah Alsabhi |Sprint-2 | Coursework/sprint 2 practice tdd Manchester | 26-ITP-Sep | Salah Alsabhi |Sprint-2 | practice tdd Oct 11, 2026
@github-actions

This comment has been minimized.

@salahalsabhi salahalsabhi changed the title Manchester | 26-ITP-Sep | Salah Alsabhi |Sprint-2 | practice tdd Manchester | 26-ITP-Sep | Salah Alsabhi | Sprint-2 | practice tdd Oct 11, 2026
@github-actions

This comment has been minimized.

@salahalsabhi salahalsabhi changed the title Manchester | 26-ITP-Sep | Salah Alsabhi | Sprint-2 | practice tdd Manchester | 26-ITP-Sep | Salah Alsabhi | Sprint 2 | practice tdd Oct 11, 2026
@salahalsabhi

Copy link
Copy Markdown
Author

Completed practice-tdd exercises with Jest tests:

  • countChar (case-insensitive counting)
  • repeatStr (no String.repeat; handles 0 and negative)
  • getOrdinalNumber (st/nd/rd/th with 11–13 exceptions)

All 12 tests pass.

@salahalsabhi salahalsabhi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 11, 2026
Comment thread practice-tdd/count.test.js Outdated
// When the function is called with these inputs,
// Then it should return 0, indicating that no occurrences of `char` were found.

test("should count multiple occurrences of a character including upper cases", () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more precise terms for describing a match that treats lowercase and uppercase letters as equivalent. Could you use AI to explore how to phrase the test description more accurately?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: For functions that deal with strings, an empty string "" is usually a good edge case to test.

Comment thread practice-tdd/get-ordinal-number.js Outdated
Comment on lines +2 to +10
return num % 100 === 11 || num % 100 === 12 || num % 100 === 13
? `${num}th`
: num % 10 === 1
? `${num}st`
: num % 10 === 2
? `${num}nd`
: num % 10 === 3
? `${num}rd`
: `${num}th`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Storing num % 100 and num % 10 in const variables with meaningful names before the conditional logic could improve readability and avoid redundant calculations.

  • Note: if-else is probably more readable than nested ? :.

Comment thread practice-tdd/get-ordinal-number.test.js Outdated
expect(getOrdinalNumber(13)).toEqual("13th");
});

test("should append 'th' for numbers ending with 0, 4, or big numbers.", () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What numbers are considered big numbers?
Is 10000001 a big number?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 16, 2026
@salahalsabhi

Copy link
Copy Markdown
Author

Thank you for your review, I addressed those things: (clearer count tests, empty string case, simplify ordinal logic)

@salahalsabhi salahalsabhi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants